package cn.marinda.resturants.mapper;

import cn.marinda.resturants.entity.Salarys;
import cn.marinda.resturants.global.Pages;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/** 工资mapper
 * @date 2021/11/16
 */
public interface SalarysMapper extends BaseMapper<Salarys> {


    /**
     * 增加工资
     *
     * @param salary 工资
     * @return int
     */
    @Insert("insert into r_salarys(uid,basic,work_duration,sundry,fill_time,leave,payable,number,version) VALUES(#{uid},#{basic},#{workDuration},#{sundry},#{fillTime},#{leave},#{payable},#{number},0)")
    int addSalarys(Salarys salary);

    /**
     * 选择列出所有
     *
     * @return {@link List}<{@link Salarys}>
     */
    @Select("select * from r_salarys")
    List<Salarys> selectListAll();

    /**
     * 选择基本 查询一个员工的基本工资
     *
     * @param uid 员工
     * @return 基本工资数据
     */
    @Select("select basic from r_salarys where uid = #{uid}")
    BigDecimal selectBasic(String uid);

    /**
     * 选择工作时间 查询一个员工的工时
     *
     * @param uid 员工号
     * @return 工时
     */
    @Select("select work_duration from r_salarys where uid = #{uid}")
    Integer selectWorkDuration(String uid);


    /** 查询一个员工的水电费
     *
     * @param uid 员工号
     * @return 水电费
     */
    @Select("select sundry from r_salarys where uid = #{uid}")
    BigDecimal selectSundry(String uid);


    /** 查询一个员工的全勤奖
     *
     * @param uid uid
     * @return 全勤奖
     */
    @Select("select fill_time from r_salarys where uid = #{uid}")
    BigDecimal selectFillTime(String uid);


    /** 查询一盒员工的请假次数
     *
     * @param uid uid
     * @return 请假次数
     */
    @Select("select leave from r_salarys where uid = #{uid}")
    Integer selectLeave(String uid);


    /** 查询应发工资
     *
     * @param uid uid
     * @return 应发工资
     */
    @Select("select payble from r_salarys where uid = #{uid}")
    BigDecimal selectPayble(String uid);


    /** 查询实发工资
     *
     * @param uid uid
     * @return 应发工资
     */
    @Select("select number from r_salarys where uid = #{uid}")
    BigDecimal selectNumber(String uid);


    /** 分页查询
     *
     * @param page 分页
     * @return 分页
     */
    @Select("select * from r_salarys ")
    IPage<Salarys> selectPages(Pages<?> page);
}
